home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / Utilities / Winter Shell 1.0d2 / Source / Libraries / GestaltLib / GestaltLib.c next >
Encoding:
C/C++ Source or Header  |  1993-12-29  |  805 b   |  37 lines  |  [TEXT/KAHL]

  1. /* Functions for using Gestalt.
  2.  
  3.     93/12/28 aih - split out of MacLib.c */
  4.  
  5. #include <GestaltEqu.h>
  6. #include "GestaltLib.h"
  7. #include "TrapLib.h"
  8.  
  9. /* true if gestalt trap is available */
  10. Boolean GestaltAvailable(void)
  11. {
  12.     static Boolean initialized, available;
  13.     
  14.     if (! initialized) {
  15.         available = TrapAvailable(_Gestalt);
  16.         initialized = true;
  17.     }
  18.     return(available);
  19. }
  20.  
  21. /* return gestalt response, or 0 if error or gestalt not available */
  22. long GestaltResponse(OSType selector)
  23. {
  24.     long response = 0;
  25.     long result = 0;
  26.     
  27.     if (GestaltAvailable() && Gestalt(selector, &response) == noErr)
  28.         result = response;
  29.     return(result);
  30. }
  31.  
  32. /* test bit in gestalt response; false if error or gestalt not available */
  33. Boolean GestaltBitTst(OSType selector, short bit)
  34. {
  35.     return(GestaltResponse(selector) & (1 << bit));
  36. }
  37.